/**
 * Created by wingsfrog on 2017/6/23.
 */
import {Injectable} from "@angular/core";
import {HttpUtils} from "../utils/http.utils";
import {USER} from "../service/user.service";
import {ParamsModel, PageParam} from "../model/params.model";

@Injectable()
export class GOODS {

  goodsApi : string = '/goods';
  rentApi:string = '/rent/order'
  cleanApi:string = '/order'
  scoreApi:string = '/score/order'
  order:string = '/order'
  constructor(private api: HttpUtils,private USER:USER) {

  }

  getList(param:any,success:any){
    let pm = new ParamsModel(this.USER);
    pm.url = this.goodsApi;
    pm.reqestData = param;
    pm.succCallback = success;
    this.api.get(pm);
  }
  purchaseRent(param:any,success:any){
    let pm = new ParamsModel(this.USER);
    pm.url = this.rentApi;
    pm.reqestData = param;
    pm.succCallback = success;
    this.api.post(pm);
  }
  purchaseClean(param:any,success:any){
    let pm = new ParamsModel(this.USER);
    pm.url = this.cleanApi;
    pm.reqestData = param;
    pm.succCallback = success;
    this.api.post(pm);
  }
  purchaseScore(param:any,success:any){
    let pm = new ParamsModel(this.USER);
    pm.url = this.scoreApi;
    pm.reqestData = param;
    pm.succCallback = success;
    this.api.post(pm);
  }

  getRentOrderList(success:any,page?:PageParam){
    let pm = new ParamsModel(this.USER);
    pm.url = this.rentApi;
    pm.reqestData = page;
    pm.succCallback = success;
    this.api.get(pm);
  }
  getCleanOrderList(success:any,page?:PageParam){
    let pm = new ParamsModel(this.USER);
    pm.url = this.cleanApi;
    pm.reqestData = page;
    pm.succCallback = success;
    this.api.get(pm);
  }
  getScoreOrderList(success:any,page?:PageParam){
    let pm = new ParamsModel(this.USER);
    pm.url = this.scoreApi;
    pm.reqestData = page;
    pm.succCallback = success;
    this.api.get(pm);
  }


}
